package com.qk.appnewslist;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by user on 2016/9/7.
 */
public class DetailsFragment extends Fragment {
    TextView tv_news_title,tv_news_content;
    /**
     * Create a new instance of DetailsFragment, initialized to
     * show the text at 'index'.
     */
    public static DetailsFragment newInstance(int index) {
        DetailsFragment f = new DetailsFragment();
        // Supply index input as an argument.
        Bundle args = new Bundle();
        args.putInt("index", index);
        f.setArguments(args);
        return f;
    }

    public int getShownIndex() {
        return getArguments().getInt("index", 0);
    }

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.detailsfragment, container, false);

        if (container == null) {return null;}

        String title =getArguments().getString("title");
        String text =getArguments().getString("text");

        tv_news_title=(TextView)view.findViewById(R.id.tv_news_title);
        tv_news_content=(TextView)view.findViewById(R.id.tv_news_content);
        tv_news_title.setText(title);
        tv_news_content.setText(text);

        return view;
    }
}
